<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('上架')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="asnbh" name="asnbh" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="cjsj" name="cjsj" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">PO编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="dycgdbh" name="dycgdbh" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">收货时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="shsj" name="shsj" />
                        </div>
                    </div>

                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload" id="search_button">搜索</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #1e9fff;color: white;"><font>重置</font></button>
                    </div>
                    <input style="display:none" type="text"  id="cjsj_start" name="cjsj_start">
                    <input style="display:none" type="text"  id="cjsj_end" name="cjsj_end">
                    <input style="display:none" type="text"  id="shsj_start" name="shsj_start">
                    <input style="display:none" type="text"  id="shsj_end" name="shsj_end">
                </form>

              <!--  <div class="group-button" id="toolbar">

                    <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 添加
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-normal edit-btn">
                        <i class="layui-icon">&#x1005;</i> 修改
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-danger delBtn">
                        <i class="iconfont">&#xe626;</i> 启用/禁用
                    </a>
                    &lt;!&ndash; Single button &ndash;&gt;
                    <div class="btn-group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            多选操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a href="#">多选删除</a></li>
                            <li><a href="#">多选打印</a></li>
                            <li><a href="#">明细表</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="#">Separated link</a></li>
                        </ul>
                    </div>
                </div>-->
                <!--列表-->
                <section class="panel panel-padding layui-card-body" >
                    <div class="pro">
                        <table id="table"  class="table text-nowrap" style="word-break:break-all; word-wrap:break-word;"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

</body>


<div th:include="public/public_js::public_js"></div>
<style type="text/css">

</style>
<script>
    $(function () {
        console.info("32332")
        console.log("我来了！！ ");
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        })
    });

    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };

    layui.use(['list','layer','zzpUtils','jquery','laydate'],function () {
        window.operateEvent ={
            "click .addAddress":function (e, value, row, index) {//增加地址
                console.info("增加地址");
                addAddressDialog(row.id);
            },

            "click .editRow":function (e, value, row, index) {

                editDialog(row.yqdhbdid);
            },
            "click .jhBtn":function (e, value, row, index) {//激活
                jhBtn(row.id);
            },


        }

        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;

         laydate.render({
            elem: '#cjsj',
             type: 'date',
             range: '~',
             done: function(value, date, endDate){
                if(value!=null && value!=""){
                    var cjsj_start=value.toString().substring(0,value.toString().indexOf("~"));
                    var cjsj_end=value.toString().substring(value.toString().indexOf("~")+1);
                    $("#cjsj_start").val(Date.parse(new Date(cjsj_start)));
                    $("#cjsj_end").val(Date.parse(new Date(cjsj_end)));
                }else {
                    $("#cjsj_start").val("");
                    $("#cjsj_end").val("");
                }


               /*  alert(Date.parse(new Date($("#cjsj_start").val())));
                 alert("2018-8-1:"+Date.parse(new Date("2018-8-1")));
                 alert("2018-08-01:"+Date.parse(new Date("2018-08-01")));*/

                 console.log(value); //得到日期生成的值，如：2017-08-18
                 console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                 console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
             }
        });
        laydate.render({
            elem: '#shsj',
            type: 'date',
            range: '~',
            done: function(value, date, endDate){
                if(value!=null && value !=""){

                }
                var shsj_start=value.toString().substring(0,value.toString().indexOf("~"));
                var shsj_end=value.toString().substring(value.toString().indexOf("~")+1);
                $("#shsj_start").val(Date.parse(new Date(shsj_start)));
                $("#shsj_end").val(Date.parse(new Date(shsj_end)));
            }
        });
        function jhBtn(id) {
            var ids=new Array(id);
            zzpUtils.confirm("是否激活",function (index) {
                zzpUtils.action({
                    url:"/wmsCustomerFiles/activation",
                    data: JSON.stringify({ids:ids}),
                    success:function (data) {
                        setTimeout(function(){
                            top.layer.msg(data.title+","+data.message);
                            zzpUtils.refreshTable("#table");
                            //刷新父页面
                        },500);
                    },error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
        }
        function editDialog(yqdhbdid){
            zzpUtils.dialog({
                title:"上架",
                type:2,
                area:['100%'],
                content: "/wmsShelvessRouter/toShelves?yqdhbdid="+yqdhbdid,
                end: function () {//添加成功后刷新
                    zzpUtils.refreshTable("#table");
                }

            });
        }

        function addAddressDialog(id){
            zzpUtils.dialog({
                title:"修改客户档案",
                type:2,
                content: "/wmsCustomerFiles/toAddAddress?id="+id,
                end: function () {//添加成功后刷新
                    zzpUtils.refreshTable("#table");
                }

            });
        }

        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/wmsshelves/list',
            columns: [{
                field: '',
                checkbox: true
            },{
                field: 'ckmc',
                title: '仓库',
                align : 'center'
            },{
                field: 'hzmc',
                title: '货主',
                align : 'center'
            },{
                field: 'asnbh',
                title: 'ASN编号',
                align : 'center'
            },{
                field: 'show_asnlx',
                title: 'ASN类型',
                align : 'center'
            },{
                field: 'show_asnzt',
                title: 'ASN状态',
                align : 'center'
            },{
                field: 'dycgdbh',
                title: 'PO编号',
                align : 'center'
            }, {
                field: 'gg',
                title: '规格',
                align : 'center'
            },{
                field: 'show_yxj',
                title: '优先级',
                align : 'center'
            },{
                field: 'yjdhsjks',
                title: '预计到货——开始',
                align : 'center'
            },  {
                field: 'yjdhsjjs',
                title: '预计到货——结束',
                align : 'center'
            },{
                field: 'cjsj',
                title: '创建时间',
                align : 'center',
                formatter:function (value, row, index) {
                    return  value.substring(0, value.lastIndexOf("."));
                }
            },{
                field: 'zdr',
                title: '制单人',
                align : 'center'
            },{
                field: 'ddshr',
                title: '审核人',
                align : 'center'
            },{
                field: 'shsj',
                title: '收货时间',
                align : 'center'
            },{
                field: 'show_zjzt',
                title: '质检状态',
                align : 'center'
            },{
                field:'caozuo',
                title: '操作',
                events:operateEvent,
                formatter:operateFormatter
            }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (row,index) {
                return "这里就没有确定过11";
            },
            onDblClickRow:function (row,index) {//双击展示
                btn_cha(row.id)
            }

        });

        function btn_cha(id) {
            var zzpUtils = layui.zzpUtils,
                $ = layui.jquery,
                laydate = layui.laydate;
            zzpUtils.dialog({
                title: "客户详情",
                type: 2,
                content: "/wmsCustomerFiles/toDetail?id=" + id,
                //设置dialog大小，也可以不设置，
            });

        }

        function operateFormatter(value, row, index) {
            return [
                '<a class="  layui-btn layui-btn-normal  layui-btn-xs editRow" >上架</a>'
            ].join('')
        }

        $(".inline-search-btn").on('click',function () {
            zzpUtils.refreshTable("#table");
        });

        $(".delBtn").on('click',function () {
            var $rows = $table.bootstrapTable('getSelections');
            if($rows.length == 0){
                layer.msg("请选择一条进行激活");
            }else{
                var ids = $.map($rows,function (row) {
                    return row.id;
                })
                zzpUtils.confirm("是否激活",function (index) {
                    zzpUtils.action({
                        url:"/wmsCustomerFiles/activation",
                        data: JSON.stringify({ids:ids}),
                        success:function (data) {
                            setTimeout(function(){
                                top.layer.msg(data.title+","+data.message);
                                zzpUtils.refreshTable("#table");
                                //刷新父页面
                            },500);
                        },error: function (xhr, textStatus) {
                            console.log(textStatus);
                            console.log(xhr)
                        }
                    })
                })
            }
        })

        $(".edit-btn").on('click',function () {
            var $rows = $table.bootstrapTable('getSelections');
            if($rows.length != 1){
                layer.msg("请选择一条进行编辑");
            }else{
                var id = $.map($rows,function (row) {
                    return row.id;
                })
                zzpUtils.dialog({
                    title: "修改客户档案",
                    type: 2,
                    content: "/wmsCustomerFiles/baseSelectDetail?id=" + id,
                    end: function () {//添加成功后刷新
                        zzpUtils.refreshTable("#table");
                    }

                })
            }


        })

        $(".add-btn").on('click',function () {
            zzpUtils.dialog({
                title:"添加客户档案",
                type:2,
                content: "/wmsCustomerFiles/toAddCustomerFile",
                btn:[],
                end: function () {//添加成功后刷新
                    zzpUtils.refreshTable("#table");
                }

            });
        })

    });
</script>
</html>